import json

import requests


class BaseApi:
    #协议层分层，方便以后出现多协议时代码重造
    def request(self, request:dict):
        if "url" in request:
            return self.http_request(request)
        if "rpc" in request:
            return self.rpc_request(request)

    def http_request(self, request):
        r = requests.request(**request)
        print(json.dumps(r.json(),indent=2,ensure_ascii=False))
        return r

    def rpc_request(self):
        pass
